// --------------------------------------------------------------------------------------------------------------------
// <copyright file="FeedEventArgs.cs" company="Open Trader">
//   Copyright (c) David Denis (david.denis@systemathics.com)
// </copyright>
// <summary>
//   |  Open Trader - The Open Source Systematic Trading Platform
//   |
//   |  This program is free software: you can redistribute it and/or modify
//   |  it under the terms of the GNU General Public License as published by
//   |  the Free Software Foundation, either version 2 of the License, or
//   |  (at your option) any later version.
//   |
//   |  This program is distributed in the hope that it will be useful,
//   |  but WITHOUT ANY WARRANTY; without even the implied warranty of
//   |  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//   |  GNU General Public License for more details.
//   |
//   |  You should have received a copy of the GNU General Public License
//   |  along with this program.  If not, see http://www.gnu.org/licenses
//   |
//   |  Up to date informations about Open Trader can be found at :
//   |    http://opentrader.org
//   |    http://opentrader.codeplex.com
//   |
//   |  For professional services, please visit us at :
//   |    http://www.systemathics.com
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace Org.OpenTrader.Framework.Forge.Events
{
    #region Usings

    using System;

    using Org.OpenTrader.Framework.Events;

    #endregion

    /// <summary>
    /// The feed event args.
    /// </summary>
    [Serializable]
    public abstract class FeedEventArgs : DispatchableEventArgs
    {
        #region Constructors and Destructors

        /// <summary>
        /// Initializes a new instance of the <see cref="FeedEventArgs"/> class.
        /// </summary>
        /// <param name="sourceId">
        /// The sourceId.
        /// </param>
        public FeedEventArgs(Guid sourceId)
            : base(sourceId)
        {
        }

        #endregion

        /// <summary>
        /// The Feed Connection Status Events ForwardToSubscriberArgs.
        /// </summary>
        [Serializable]
        public class ConnectionStatus : FeedEventArgs
        {
            #region Constructors and Destructors

            /// <summary>
            /// Initializes a new instance of the <see cref="ConnectionStatus"/> class.
            /// </summary>
            /// <param name="connectionArgs">
            /// The Connection args.
            /// </param>
            public ConnectionStatus(ConnectionEventArgs connectionArgs)
                : base(Guid.Empty)
            {
                this.ConnectionArgs = connectionArgs;
            }

            #endregion

            #region Properties

            /// <summary>
            /// Gets ConnectionArgs.
            /// </summary>
            public ConnectionEventArgs ConnectionArgs { get; private set; }

            #endregion

            #region Public Methods

            /// <summary>
            /// The to string.
            /// </summary>
            /// <returns>
            /// The to string.
            /// </returns>
            public override string ToString()
            {
                return string.Format("ConnectionStatus[ConnectionArgs={0}]", this.ConnectionArgs);
            }

            #endregion
        }

        /// <summary>
        /// The market book update.
        /// </summary>
        [Serializable]
        public class MarketBookUpdate : FeedEventArgs
        {
            #region Constructors and Destructors

            /// <summary>
            /// Initializes a new instance of the <see cref="MarketBookUpdate"/> class. 
            /// Initializes a new instance of the <see cref="MarketBookCell"/> class.
            /// </summary>
            /// <param name="sourceId">
            /// The sourceId.
            /// </param>
            /// <param name="updates">
            /// The updates.
            /// </param>
            /// <param name="isSnapshot">
            /// The is Snapshot.
            /// </param>
            public MarketBookUpdate(Guid sourceId, MarketBookCell[] updates, bool isSnapshot)
                : base(sourceId)
            {
                this.Cells = updates;
                this.IsSnapshot = isSnapshot;
            }

            #endregion

            #region Properties

            /// <summary>
            /// Gets or sets Fields.
            /// </summary>
            public MarketBookCell[] Cells { get; set; }

            /// <summary>
            /// Gets a value indicating whether IsSnapshot.
            /// </summary>
            public bool IsSnapshot { get; private set; }

            #endregion

            #region Public Methods

            /// <summary>
            /// The to string.
            /// </summary>
            /// <returns>
            /// The to string.
            /// </returns>
            public override string ToString()
            {
                return string.Format("MarketBookCell[SourceID={0};UpdatesCount={1}]", this.ObjectID, this.Cells.Length);
            }

            #endregion
        }

        /// <summary>
        /// The market field update event args.
        /// </summary>
        [Serializable]
        public class MarketFieldUpdate : FeedEventArgs
        {
            #region Constructors and Destructors

            /// <summary>
            /// Initializes a new instance of the <see cref="MarketFieldUpdate"/> class. 
            /// Initializes a new instance of the <see cref="MarketField"/> class.
            /// </summary>
            /// <param name="sourceId">
            /// The sourceId.
            /// </param>
            /// <param name="updates">
            /// The updates.
            /// </param>
            /// <param name="isSnapshot">
            /// The is Snapshot.
            /// </param>
            public MarketFieldUpdate(Guid sourceId, MarketField[] updates, bool isSnapshot)
                : base(sourceId)
            {
                this.Fields = updates;
                this.IsSnapshot = isSnapshot;
            }

            #endregion

            #region Properties

            /// <summary>
            /// Gets or sets Fields.
            /// </summary>
            public MarketField[] Fields { get; set; }

            /// <summary>
            /// Gets a value indicating whether IsSnapshot.
            /// </summary>
            public bool IsSnapshot { get; private set; }

            #endregion

            #region Public Methods

            /// <summary>
            /// The to string.
            /// </summary>
            /// <returns>
            /// The to string.
            /// </returns>
            public override string ToString()
            {
                return string.Format("MarketField[SourceID={0};UpdatesCount={1}]", this.ObjectID, this.Fields.Length);
            }

            #endregion
        }

        /// <summary>
        /// The market quote update.
        /// </summary>
        [Serializable]
        public class MarketQuoteUpdate : FeedEventArgs
        {
            #region Constructors and Destructors

            /// <summary>
            /// Initializes a new instance of the <see cref="MarketQuoteUpdate"/> class. 
            /// Initializes a new instance of the <see cref="MarketQuote"/> class.
            /// </summary>
            /// <param name="sourceId">
            /// The source id.
            /// </param>
            /// <param name="updates">
            /// The updates.
            /// </param>
            /// <param name="isSnapshot">
            /// The is snapshot.
            /// </param>
            public MarketQuoteUpdate(Guid sourceId, MarketQuote[] updates, bool isSnapshot)
                : base(sourceId)
            {
                this.Quotes = updates;
                this.IsSnapshot = isSnapshot;
            }

            #endregion

            #region Properties

            /// <summary>
            /// Gets a value indicating whether IsSnapshot.
            /// </summary>
            public bool IsSnapshot { get; private set; }

            /// <summary>
            /// Gets or sets Fields.
            /// </summary>
            public MarketQuote[] Quotes { get; set; }

            #endregion

            #region Public Methods

            /// <summary>
            /// The to string.
            /// </summary>
            /// <returns>
            /// The to string.
            /// </returns>
            public override string ToString()
            {
                return string.Format("MarketQuote[SourceID={0};UpdatesCount={1}]", this.ObjectID, this.Quotes.Length);
            }

            #endregion
        }
    }
}